<template>
	<div>
		<Card class="content-card">
			<Tabs :animated="false">
				<ButtonGroup slot="extra">

					<Button type="primary" size="small" icon="md-refresh" @click="refreshData"></Button>
				</ButtonGroup>
				<TabPane label="配件退货列表" name="repair">
					<div class="form_group">
						<div class="inputbox">
							<span>状态</span>
							<Select v-model="params.type" style="width:200px;">
								<Option value="">全部</Option>
								<Option v-for="(item,key) in stateList" :value="key">{{ item }}</Option>
							</Select>
						</div>
						<div class="inputbox">
							<Button type="primary" @click="refreshData">查询</Button>
						</div>
					</div>
					<table-view ref="tableView" :tableCol='tableCol' :params="params" :requestUrl='requestUrl'></table-view>
				</TabPane>
			</Tabs>
		</Card>
	</div>
</template>

<script>
    import tableView from '../../components/table'
    import {
        formatDate
    } from '../utils/time.js'
    export default {
        components: {
            tableView
        },
        data() {
            return {
                requestUrl: '/parts/return/list',
                stateList: {
                    0: "待审核",
                    1: "审核通过",
                    2: "审核未通过",
                    3: "待收货",
                    4: "待退款",
                    5: "待确认",
                    6: "退款完成"
                },
                tableCol: [{
                    title: '序号',
                    type: 'index',
                    width: 70
                }, {
					title: '订单号',
					key: 'orderNum'
				}, {
					title: '状态',
					key: 'state',
					render: (h, params) => {
						return h("div", this.stateList[params.row.returnType]);
					}
				}, {
					title: '操作',
					key: 'action',
					render: (h, params) => {
						return h('div', [
							h('Button', {
								props: {
									type: 'primary',
									size: 'small'
								},
								on: {
									click: () => {
										this.$router.push({
											path:'/partsReturnDetail',
											query: {
												id: params.row.returnId
											}
										});
									}
								}
							}, '详情')
						])
					}
				}],
                params: {
                    pageNo: 1,
                    pageSize: 10,
                    sellerId: sessionStorage.getItem("factoryId"),
                    type: ''
                }
            }
        },
        mounted() {

        },
        methods: {
            refreshData() {
                this.$refs['tableView'].getData()
            }
        }
    }
</script>
<style scoped>
	.content-card{
		width: 100%;
	}
	.form_group {
		margin-bottom: 15px;
	}
	.inputbox {
		display: inline-block;
		margin-right: 15px;
	}
	.inputbox span {
		margin-right: 5px;
	}
</style>
<style>
	.ivu-tabs {
		overflow: inherit;
	}
</style>